package licode.unisop.log.service.adapter.controller;

import licode.unisop.log.client.dto.AuditLogDTO;
import licode.unisop.log.client.dto.CallingLogDTO;
import licode.unisop.log.client.dto.LoginLogDTO;
import licode.unisop.log.service.application.executor.LogLogsExecutor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 适配RESTFUL接口访问，处理用户的注册和登录
 *
 * @author WR
 */
@RestController
@RequestMapping("/auth-log/api/v1")
public class LogsController extends BaseController {
    @Resource
    private LogLogsExecutor logLogsExecutor;

    @PostMapping("/audit/save")
    public void saveAudit(@RequestBody AuditLogDTO data) {
        checkPlatform();
        logLogsExecutor.saveAudit(data);
    }

    @PostMapping("/call-api/save")
    public void saveCallApi(@RequestBody CallingLogDTO data) {
        checkPlatform();
        logLogsExecutor.saveCallingLog(data);
    }

    @PostMapping("/login/save")
    public void saveLogin(@RequestBody LoginLogDTO data) {
        checkPlatform();
        logLogsExecutor.saveLogin(data);
    }
}
